package com.itheima.demo1;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class MapDemo1 {

    public static void main(String[] args) {

        Map<String,String> m =new HashMap<>();

        m.put("杨过","小龙女");
        m.put("郭靖","黄蓉");
        m.put("韦小宝","双儿");

//        Set<String> s = m.keySet();

        //利用map集合中的键获取对应的值  get
//        s.forEach(s1 -> System.out.println(m.get(s1)));



        //根据键值对进行遍历

        //Entry是map集合中的内部接口，调用时要么导包要么前面加上类名map
        /*Set<Map.Entry<String, String>> entries = m.entrySet();
        //遍历
        for (Map.Entry<String, String> entry : entries) {
            String key = entry.getKey();
            String value = entry.getValue();
            System.out.println(key + " = " + value);
        }*/

        m.forEach((k,v)-> System.out.println(k +" = "+v));

    }
}
